#!/bin/sh -e

scaling_governor=$1
[ -n "$scaling_governor" ] || exit 0

. $LKP_SRC/lib/env.sh
is_virt && exit 0
is_docker && exit 0

[ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] || exit 0

. $LKP_SRC/lib/reproduce-log.sh

log_echo '
for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*
do
	online_file="$cpu_dir"/online
	[ -f "$online_file" ] && [ "$(cat "$online_file")" -eq 0 ] && continue

	file="$cpu_dir"/cpufreq/scaling_governor
	[ -f "$file" ] && echo "'"$scaling_governor"'" > "$file"
done
'

for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*
do
	online_file="$cpu_dir"/online
	[ -f "$online_file" ] && [ "$(cat "$online_file")" -eq 0 ] && continue

	file="$cpu_dir"/cpufreq/scaling_governor
	[ -f "$file" ] && echo "$scaling_governor" > "$file"
done
